﻿// <copyright file="AboutControl.xaml.cs" company="Mooville">
//   Copyright © 2010 Roger Deetz. All rights reserved.
// </copyright>

namespace Mooville.QUno.Store
{
    using System;
    using System.Globalization;
    using System.Reflection;
    using Windows.ApplicationModel;
    using Windows.UI.ApplicationSettings;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;

    public sealed partial class AboutControl : UserControl
    {
        public AboutControl()
        {
            this.InitializeComponent();

            if (!DesignMode.DesignModeEnabled)
            {
                this.Loaded += this.Control_Loaded;
                this.buttonBack.Click += this.BackButton_Click;
            }
        }

        private void Control_Loaded(object sender, RoutedEventArgs e)
        {
            Assembly assembly = typeof(AboutControl).GetTypeInfo().Assembly;
            AssemblyFileVersionAttribute attribute = assembly.GetCustomAttribute<AssemblyFileVersionAttribute>();
            string version = attribute.Version;

            this.textVersion.Text = String.Format(CultureInfo.CurrentCulture, this.textVersion.Text, version.ToString());

            return;
        }

        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.Parent.GetType() == typeof(Popup))
            {
                ((Popup)this.Parent).IsOpen = false;
            }

            SettingsPane.Show();

            return;
        }
    }
}
